package com.huawei.hwid.core.a;

import android.content.Context;
import android.os.Bundle;
import com.huawei.hwid.core.b.a.a;
import com.huawei.hwid.core.d.b;
import com.huawei.hwid.core.d.b.e;

public class c {
    private static boolean a = true;
    private static volatile int b = 0;
    private static int c = 0;

    public static synchronized void a(Bundle bundle, Context context) {
        synchronized (c.class) {
            if (bundle != null) {
                a(new b(bundle, context), context);
            }
        }
    }

    public static synchronized void a(b bVar, Context context) {
        synchronized (c.class) {
            e.b("OpLogUtil", "recordOpLog", true);
            if (!(bVar == null || context == null)) {
                c = bVar.a();
                if (b == 0) {
                    a.a(context).a(bVar);
                    b(context);
                } else if (b == 1) {
                    a.a(context).b(bVar);
                }
            }
        }
    }

    private static synchronized void b(Context context) {
        synchronized (c.class) {
            if (a && b.a(context) && !a.a(context).b().isEmpty()) {
                a cVar = new com.huawei.hwid.core.b.a.a.c(a.a(context).toString());
                if (c > 0 && c <= 999) {
                    cVar.a(context, c);
                }
                cVar.a(context, cVar, null, null);
                b = 1;
            }
        }
    }

    public static synchronized void a(Context context) {
        synchronized (c.class) {
            if (!a.a(context).c().isEmpty()) {
                a.a(context).d();
                b(context);
            }
        }
    }

    public static synchronized void a(int i) {
        synchronized (c.class) {
            b = i;
        }
    }
}
